/*
 * Copyright © 2024-2025 Wenze Wei
 *
 * This file is part of StadionOS.
 *
 * This Source Code Form is subject to the terms of the GNU General Public License, v. 2.0.
 * You can obtain a copy of the GPL at
 * https://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 */

#include "test.h"

void test_memory_management() {
    Sprint("Testing Memory Management...\n");

    void *p1 = Smalloc(100);
    if (p1) Sprint("Successfully allocated 100 bytes.\n");
    void *p2 = Smalloc(200);
    if (p2) Sprint("Successfully allocated 200 bytes.\n");

    Sfree(p1);
    Sprint("Release 100 bytes.\n");

    void *p3 = Srealloc(p2, 300);
    if (p3) Sprint("Reassignment to 300 bytes successful.\n");

    void *p4 = Scalloc(5, 20);
    if (p4) Sprint("Successfully allocated 5 20 bytes (cleared).\n");

    Sfree(p3);
    Sfree(p4);
    Sprint("Release all allocated memory.\n");
}
